package pATT.DataSetsGenerator.dataSetsGenerator.generator.implement;

import java.util.Random;
import java.util.Vector;

import pATT.DataSetsGenerator.dataSetsGenerator.attribute.implement.Attribute;
import pATT.DataSetsGenerator.dataSetsGenerator.core.implement.Relation;
import pATT.DataSetsGenerator.dataSetsGenerator.data.implement.IData;
import pATT.DataSetsGenerator.dataSetsGenerator.data.implement.Data;


public class RandomGenerator extends Generator{
	
	public RandomGenerator(Relation relat) {
		super(relat);
	}
	
	private double random(){
		double doub;
		Random randomWord= new Random();
		doub=randomWord.nextDouble();
		return doub;
	}
	
	/*
	 @SuppressWarnings("unchecked")
	 public Vector random (IRandomData data){
	 int totalRul = getRelation().getExamples();
	 //Vector att = attribute.getValues();
	  Vector att = ((RandomData)data).getAttribute().getValues();
	  Vector result = new Vector();
	  String val = "";
	  for (int i = 0; i < totalRul; i++) {		
	  val = (String) att.elementAt(random()*(att.size()));//agrego demas valores sin "value"
	  result.addElement(val);
	  }
	  return result;
	  }
	  */	
	
	@SuppressWarnings("unchecked")
	public Vector generate (IData data){
		int totalRul = getRelation().getExamples();
		Vector result = new Vector();
		String val = "##";
		for (int i = 0; i < totalRul; i++) {		
			result.addElement(val);
		}
		return result;
	}
	
	
	@SuppressWarnings("unchecked")
	public String randomValue (IData data){
		Vector att = ((Data)data).getAttribute().getValues();
		String val = (String) att.elementAt((int)(random()*(att.size())));//agrego demas valores sin "value"
		return val;
	}
	
	
	
//	probar	
	@SuppressWarnings("unchecked")
	public String randomTupla(Vector<Attribute> attributes){
		String tupla = "";
		String value = "";
		Vector attValues = null;
		for (int i = 0; i < attributes.size(); i++) {
			attValues = attributes.elementAt(i).getValues();
			value = (String) attValues.elementAt((int)(random()*(attValues.size())));
			tupla+=value;			
			if(i != attributes.size()-1)
				tupla+=",";
		}
		return tupla;
	}
	
}

